package com.tloss.bean;

import java.util.List;

import com.tloss.stdao.StockHistory;
import com.tloss.stdao.service.ResidualStockService;
import com.tloss.stdao.service.StockHistoryService;

public class TransactionHistoryBean {
	StockHistory history;
	StockHistoryService historyService;
	ResidualStockService residualStockService;

	public TransactionHistoryBean() {
		historyService = new StockHistoryService();
		residualStockService = new ResidualStockService();
	}

	public void setHistory(StockHistory history) {
		this.history = history;
	}

	public StockHistory getHistory() {
		return history;
	}

	public String save() {
		historyService.insert(history);
		residualStockService.update(history.getUsername(), history.getStock(),
				history.getValue(), history.getQuality(),
				history.getTransactionType());
		return "true";
	}

	public List<StockHistory> getHistories() {
		return historyService.select(history.getUsername());
	}
}
